
#include "../ui.h"
#include "../app_includes.h"


static lv_obj_t *ui_screen;

static lv_obj_t *ui_BtnPowerOff;
static lv_obj_t *ui_BtnReset;

static void btn_power_off_event_cb(lv_event_t * e);
static void btn_power_reset_event_cb(lv_event_t * e);

lv_obj_t *lv_power_off_load(void)
{
    lv_obj_t *t;
    ui_screen = lv_screen_create(ui_main_screen.desktop, LV_HOR_RES, LV_VER_RES);
    
    ui_BtnPowerOff = lv_btn_create(ui_screen);
    lv_obj_set_width( ui_BtnPowerOff, 120);
    lv_obj_set_height( ui_BtnPowerOff, 40);
    lv_obj_align( ui_BtnPowerOff, LV_ALIGN_CENTER, 0, -80 );
    lv_obj_add_flag( ui_BtnPowerOff, LV_OBJ_FLAG_SCROLL_ON_FOCUS );   /// Flags
    lv_obj_clear_flag( ui_BtnPowerOff, LV_OBJ_FLAG_SCROLLABLE );    /// Flags
    lv_obj_set_style_radius(ui_BtnPowerOff, 10, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_BtnPowerOff, lv_color_hex(0x191D26), LV_PART_MAIN | LV_STATE_DEFAULT );
    lv_obj_set_style_bg_opa(ui_BtnPowerOff, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_border_color(ui_BtnPowerOff, lv_color_hex(0x00B4B4), LV_PART_MAIN | LV_STATE_DEFAULT );
    lv_obj_set_style_border_opa(ui_BtnPowerOff, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_BtnPowerOff, 2, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_BtnPowerOff, lv_color_hex(0x191D26), LV_PART_MAIN | LV_STATE_CHECKED );
    lv_obj_set_style_bg_opa(ui_BtnPowerOff, 255, LV_PART_MAIN| LV_STATE_CHECKED);
    lv_obj_set_style_border_color(ui_BtnPowerOff, lv_color_hex(0x3EF33A), LV_PART_MAIN | LV_STATE_CHECKED );
    lv_obj_set_style_border_opa(ui_BtnPowerOff, 255, LV_PART_MAIN| LV_STATE_CHECKED);
    lv_obj_set_style_border_width(ui_BtnPowerOff, 2, LV_PART_MAIN| LV_STATE_CHECKED);
    
    ui_BtnReset = lv_btn_create(ui_screen);
    lv_obj_set_width( ui_BtnReset, 120);
    lv_obj_set_height( ui_BtnReset, 40);
    lv_obj_align( ui_BtnReset, LV_ALIGN_CENTER, 0, 80 );
    lv_obj_add_flag( ui_BtnReset, LV_OBJ_FLAG_SCROLL_ON_FOCUS );   /// Flags
    lv_obj_clear_flag( ui_BtnReset, LV_OBJ_FLAG_SCROLLABLE );    /// Flags
    lv_obj_set_style_radius(ui_BtnReset, 10, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_BtnReset, lv_color_hex(0x191D26), LV_PART_MAIN | LV_STATE_DEFAULT );
    lv_obj_set_style_bg_opa(ui_BtnReset, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_border_color(ui_BtnReset, lv_color_hex(0x00B4B4), LV_PART_MAIN | LV_STATE_DEFAULT );
    lv_obj_set_style_border_opa(ui_BtnReset, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_BtnReset, 2, LV_PART_MAIN| LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_BtnReset, lv_color_hex(0x191D26), LV_PART_MAIN | LV_STATE_CHECKED );
    lv_obj_set_style_bg_opa(ui_BtnReset, 255, LV_PART_MAIN| LV_STATE_CHECKED);
    lv_obj_set_style_border_color(ui_BtnReset, lv_color_hex(0x3EF33A), LV_PART_MAIN | LV_STATE_CHECKED );
    lv_obj_set_style_border_opa(ui_BtnReset, 255, LV_PART_MAIN| LV_STATE_CHECKED);
    lv_obj_set_style_border_width(ui_BtnReset, 2, LV_PART_MAIN| LV_STATE_CHECKED);
    
    t = lv_label_create(ui_BtnPowerOff);
    lv_obj_set_width( t, LV_SIZE_CONTENT);  /// 1
    lv_obj_set_height( t, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_align( t, LV_ALIGN_CENTER );
    lv_label_set_text(t,"关机");
    lv_obj_set_style_text_font(t, &ui_font_FontChinese, LV_PART_MAIN| LV_STATE_DEFAULT);
    
    t = lv_label_create(ui_BtnReset);
    lv_obj_set_width( t, LV_SIZE_CONTENT);  /// 1
    lv_obj_set_height( t, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_align( t, LV_ALIGN_CENTER );
    lv_label_set_text(t,"重启");
    lv_obj_set_style_text_font(t, &ui_font_FontChinese, LV_PART_MAIN| LV_STATE_DEFAULT);
    
    
    lv_obj_add_event_cb(ui_BtnPowerOff, btn_power_off_event_cb, LV_EVENT_CLICKED, NULL);
    lv_obj_add_event_cb(ui_BtnReset, btn_power_reset_event_cb, LV_EVENT_CLICKED, NULL);
    
    return ui_screen;
}


static void btn_power_off_event_cb(lv_event_t * e)
{
    board_power_off();
}

static void btn_power_reset_event_cb(lv_event_t * e)
{
    board_reset();
}
